
package net.sourceforge.peers.sip.syntaxencoding;

/**
 * 请求头字段 field-name
 * @author Mr.Yan
 */
public class SipHeaderFieldName {

    /**
     * RFC3261标准的常用字段表
     */
    private final static SipHeadersTable SIP_HEADER_TABLE = new SipHeadersTable();

    private final String name;

    public SipHeaderFieldName(String name) {
        if (name.length() == 1) {
            this.name = SIP_HEADER_TABLE.getLongForm(name.charAt(0));
        } else {
            this.name = name;
        }
    }

    @Override
    public boolean equals(Object obj) {

        if (obj == null) {
            return false;
        }
        String objName="";
        if(obj instanceof SipHeaderFieldName){
            objName= ((SipHeaderFieldName)obj).getName();

        }
        return name.equalsIgnoreCase(objName);
    }

    @Override
    public int hashCode() {
        return name.hashCode();
    }
    
    public String getName() {
        return name;
    }
    
    @Override
    public String toString() {
        return name;
    }
}
